<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">

            <h:form id="registrationForm" enctype="multipart/form-data">

                <h3 class="title">Averbação de Desmembramento</h3>

                <p:panel id="imovelPanel" styleClass="container_24 clearfix withoutBorder">
                    <h4 class="title">Dados do Imóvel</h4>

                    <p:outputLabel value="Inscrição" styleClass="grid_4"/>
                    <p:inputMask mask="?**.**.***.****.**" id="maskinscricao" readonly="true"
                                 styleClass="grid_6" value="#{managerAverbacao.inscricaoImovel}"/>
                    <div class="clear"/>

                    <p:outputLabel value="Localização" styleClass="grid_4"/>
                    <p:inputText value="Logradouro #{managerAverbacao.imovel.enderecoImovel.logradouro}, bairro #{managerAverbacao.imovel.enderecoImovel.bairroDne.nome}"
                                 styleClass="grid_19" readonly="true"/>
                    <div class="clear"/>

                    <p:outputLabel value="Proprietário" styleClass="grid_4"/>
                    <p:inputText value="#{managerAverbacao.nomeDosProprietarios(managerAverbacao.imovel)}" 
                                 styleClass="grid_19" readonly="true"/>
                    <div class="clear"/>

                    <p:outputLabel value="Área Terreno" styleClass="grid_4"/>
                    <p:inputText value="#{managerAverbacao.imovel.dimensoes.areaTerreno}" styleClass="grid_4" readonly="true"/>  
                </p:panel>

                <br/>
                <div style="float: left;width: 100%; margin-bottom: 10px">
                    <p:commandButton value="Novo Imóvel" actionListener="#{managerAverbacao.limpaNovosProprietarios()}" 
                                     icon="ui-icon-plus" update="@form"  process="@this" 
                                     style="float: right;margin-right: 15px" 
                                     oncomplete="dlgUsarDadosImovel.show()" />
                </div>
                <p:growl id="messages" showDetail="false" autoUpdate="true"/> 

                <p:panel id="panel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix ">

                    <p:dataTable id="tableImoveis" var="item" value="#{managerAverbacao.imoveis}" 
                                 styleClass="grid_24" emptyMessage="Nenhum registro">  
                        <f:facet name="header">
                            Imóveis
                        </f:facet>
                        <p:column headerText="Remover" width="50">
                            <p:commandButton styleClass="optionButton" alt="Editar"
                                             process="@this" icon="ui-icon-pencil"
                                             update="tableImoveis, :registrationForm:dlgImovel"
                                             oncomplete="dlgImovel.show()"
                                             actionListener="#{managerAverbacao.editarImovel(item)}" />
                            <p:commandButton styleClass="optionButton" alt="Remover"
                                             process="@this" icon="ui-icon-trash"
                                             update="tableImoveis"
                                             actionListener="#{managerAverbacao.removeImovel(item)}" />

                        </p:column>

                        <p:column headerText="Localização">  
                            <ui:repeat value="#{item.enderecoImovel}" var="i">
                                <h:outputText value="Logradouro #{i.logradouro}, bairro #{i.bairro}"/>
                            </ui:repeat>
                        </p:column>
                        <p:column headerText="Proprietário" width="300">  
                            <p:outputLabel value="#{managerAverbacao.nomeDosProprietarios(item)}" />
                        </p:column> 
                        <p:column headerText="Área" width="100">  
                            <p:outputLabel value="#{item.dimensoes.areaTerreno}" />  
                        </p:column> 
                    </p:dataTable>   

                    <div class="buttonAction">
                        <p:commandButton value="Salvar" icon="ui-icon-disk" 
                                         actionListener="#{managerAverbacao.salvarAverbacaoDesmembramento()}"
                                         update="@form" process="@this" rendered="#{managerAverbacao.btDisable}"
                                         styleClass="ui-priority-primary" />

                        <p:commandButton  actionListener="#{managerAverbacao.redirectAverbacao()}"  process="@this" value="Cancelar"   icon="ui-icon-trash" />
                    </div>

                    <p:dialog widgetVar="dlgImovel" id="dlgImovel" modal="true" header="Novo Imóvel" height="450"
                              width="960" closeOnEscape="true">

                        <p:panel id="inscricaoPanel" styleClass="container_24 clearfix withoutBorder">
                            <h4 class="title">Inscrição Cadastral</h4>

                            <p:outputLabel value="Lote" styleClass="grid_3" for="loteImovel"/>
                            <p:inputText id="loteImovel" value="#{managerAverbacao.novoImovel.inscricaoCadastralLote}" styleClass="grid_4"/>
                        </p:panel>

                        <p:panel id="personPanel" styleClass="container_24 clearfix both withoutBorder">
                            <h4 class="title">Proprietários</h4>

                            <div style="float: right; margin-bottom: 10px">
                                <p:commandButton value="Adicionar Proprietário" title="Adicionar Proprietário" 
                                                 icon="ui-icon-plus" process="@this" 
                                                 style="float: right;margin-right: 15px" 
                                                 onclick="dlgProprietario.show()" />
                            </div>

                            <p:panel id="panelP" styleClass="container_24 clearfix withoutBorder">

                                <p:dataTable id="tableProprietario" var="item" value="#{managerAverbacao.novosProprietarios}" 
                                             styleClass="grid_24" emptyMessage="Nenhum registro">  
                                    <f:facet name="header">
                                        Novos Proprietários
                                    </f:facet>

                                    <p:column headerText="Ação"  >
                                        <p:commandButton icon="ui-icon-trash" title="Remover" 
                                                         process="@this" update="tableProprietario" 
                                                         actionListener="#{managerAverbacao.removeProprietario(item)}" />
                                    </p:column>

                                    <p:column headerText="Nome">  
                                        #{item.tipoDocumento ne null ? 
                                          (item.tipoDocumento eq 'CPF' ? item.nome : item.nomeFantasia) : 
                                          (item.nome ne null and item.nome ne '' ? item.nome : item.nomeFantasia)}
                                    </p:column>

                                    <p:column headerText="Documento" >  
                                        #{item.formatedDocument()}
                                    </p:column> 

                                </p:dataTable>
                            </p:panel>
                        </p:panel>

                        <p:panel id="dimenPanel" styleClass="container_24 clearfix withoutBorder">
                            <h4 class="title">Dimensões e Confrontações</h4>

                            <fieldset>
                                <legend>Frente</legend>
                                <p:outputLabel value="Para" styleClass="grid_3" for="frenteInputText" />
                                <p:inputText id="frenteInputText" styleClass="grid_18"
                                             value="#{managerAverbacao.novoImovel.frente}" />
                                <div class="clear"/>

                                <p:outputLabel value="Rua" styleClass="grid_3" for="frenteRuaInputText" />
                                <p:inputText id="frenteRuaInputText" styleClass="grid_18"
                                             value="#{managerAverbacao.novoImovel.frenteRua}" />
                                <div class="clear"/>

                                <p:outputLabel value="Medindo" styleClass="grid_3" for="frenteMedInputText" />
                                <p:inputText id="frenteMedInputText" styleClass="grid_18"
                                             value="#{managerAverbacao.novoImovel.frenteMedindo}" />
                                <div class="clear"/>
                            </fieldset>

                            <fieldset>
                                <legend>Lado direito</legend>
                                <p:outputLabel value="Para" styleClass="grid_3" for="direitoParaInputText" />
                                <p:inputText id="direitoParaInputText" styleClass="grid_18" 
                                             value="#{managerAverbacao.novoImovel.ladoDireito}" />
                                <div class="clear"/>

                                <p:outputLabel value="Rua" styleClass="grid_3" for="direitoRuaInputText" />
                                <p:inputText id="direitoRuaInputText" styleClass="grid_18" 
                                             value="#{managerAverbacao.novoImovel.ladoDireitoRua}" />
                                <div class="clear"/>

                                <p:outputLabel value="Medindo" styleClass="grid_3" for="direitoMedInputText" />
                                <p:inputText id="direitoMedInputText" styleClass="grid_18" 
                                             value="#{managerAverbacao.novoImovel.ladoDireitoMedindo}" />
                                <div class="clear"/>
                            </fieldset>

                            <fieldset>
                                <legend>Lado Esquerdo</legend>
                                <p:outputLabel value="Para" styleClass="grid_3" for="esquerdoInputText" />
                                <p:inputText id="esquerdoInputText" styleClass="grid_18" 
                                             value="#{managerAverbacao.novoImovel.ladoEsquerdo}" />
                                <div class="clear"/>

                                <p:outputLabel value="Rua" styleClass="grid_3" for="esquerdoRuaInputText" />
                                <p:inputText id="esquerdoRuaInputText" styleClass="grid_18" 
                                             value="#{managerAverbacao.novoImovel.ladoEsquerdoRua}" />
                                <div class="clear"/>

                                <p:outputLabel value="Medindo" styleClass="grid_3" for="esquerdoMedInputText" />
                                <p:inputText id="esquerdoMedInputText" styleClass="grid_18" 
                                             value="#{managerAverbacao.novoImovel.ladoEsquerdoMedindo}" />
                                <div class="clear"/>
                            </fieldset>

                            <fieldset>
                                <legend>Fundo</legend>
                                <p:outputLabel value="Para" styleClass="grid_3" for="fundoInputText" />
                                <p:inputText id="fundoInputText" styleClass="grid_18" 
                                             value="#{managerAverbacao.novoImovel.fundo}" />
                                <div class="clear"/>
                                <p:outputLabel value="Rua" styleClass="grid_3" for="fundoRuaInputText" />
                                <p:inputText id="fundoRuaInputText" styleClass="grid_18" 
                                             value="#{managerAverbacao.novoImovel.fundoRua}" />
                                <div class="clear"/>
                                <p:outputLabel value="Medindo" styleClass="grid_3" for="fundoMedInputText" />
                                <p:inputText id="fundoMedInputText" styleClass="grid_18" 
                                             value="#{managerAverbacao.novoImovel.fundoMedindo}" />
                                <div class="clear"/>
                            </fieldset>
                            <br/>

                            <h5 class="title">Dimensões Terreno</h5>
                            <br/>
                            <p:outputLabel value="Área Terreno" styleClass="grid_5" for="areaInputText" />
                            <p:inputText id="areaInputText" styleClass="grid_4" required="true"
                                         
                                         value="#{managerAverbacao.novoImovel.dimensoes.areaTerreno}"
                                         onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                                <f:convertNumber pattern="#,###,##0.00" locale="pt,BR"/>
                            </p:inputText>

                            <p:outputLabel value="Área Unidade" styleClass="grid_8 alpha" for="areaUInputText" />
                            <p:inputText id="areaUInputText" styleClass="grid_4"
                                         value="#{managerAverbacao.novoImovel.dimensoes.areaUnidade}"
                                         onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                                <f:convertNumber pattern="#,###,##0.00" locale="pt,BR"/>
                            </p:inputText>

                            <div class="clear"/>
                            <p:outputLabel value="Área Total" styleClass="grid_5" for="areaTInputText" />
                            <p:inputText id="areaTInputText" styleClass="grid_4"
                                         value="#{managerAverbacao.novoImovel.dimensoes.areaTotalEdificacao}"
                                         onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                                <f:convertNumber pattern="#,###,##0.00" locale="pt,BR"/>
                            </p:inputText>

                            <p:outputLabel value="Nº Pavimento" styleClass="grid_8 alpha" for="areaPInputText" />
                            <p:inputText id="areaPInputText" styleClass="grid_4"
                                         value="#{managerAverbacao.novoImovel.dimensoes.numPavimentacaoEdific}">
                            </p:inputText>
                            <div class="clear"/>
                            <br/>

                            <div class="clear"/>
                            <h5 class="title">Testada</h5>
                            <br/>
                            <p:outputLabel value="Testada do Imóvel" styleClass="grid_5" for="areaTiInputText" />
                            <p:inputText id="areaTiInputText" styleClass="grid_4"
                                         value="#{managerAverbacao.novoImovel.dimensoes.testadaImovel}"
                                         onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                                <f:convertNumber pattern="#,###,##0.00" locale="pt,BR"/>
                            </p:inputText>

                            <p:outputLabel value="Servida Conservação Calçamento" styleClass="grid_8 alpha" for="areaTSInputText" />
                            <p:inputText id="areaTSInputText" styleClass="grid_4"
                                         value="#{managerAverbacao.novoImovel.dimensoes.testadaServidaConservCalcamento}"
                                         onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                                <f:convertNumber pattern="#,###,##0.00" locale="pt,BR"/>
                            </p:inputText>

                            <div class="clear"/>
                            <p:outputLabel value="Servida Iluminação Pública" styleClass="grid_5" for="areaTIInputText" />
                            <p:inputText id="areaTIInputText" styleClass="grid_4"
                                         value="#{managerAverbacao.novoImovel.dimensoes.testadaServidaPorIluminacaoPublica}"
                                         onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                                <f:convertNumber pattern="#,###,##0.00" locale="pt,BR"/>
                            </p:inputText>

                            <p:outputLabel value="Servida Limpeza Pública" styleClass="grid_8 alpha" for="areaTLInputText" />
                            <p:inputText id="areaTLInputText" styleClass="grid_4"
                                         value="#{managerAverbacao.novoImovel.dimensoes.testadaServidaLimpezaPublica}"
                                         onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                                <f:convertNumber pattern="#,###,##0.00" locale="pt,BR"/>
                            </p:inputText>

                        </p:panel>

                        <div class="clear"/>

                        <div class="buttonAction">
                            <p:commandButton value="Adicionar" icon="ui-icon-circle-plus"
                                             actionListener="#{managerAverbacao.addImovel()}"
                                             update=":registrationForm:tableImoveis, @form"
                                             styleClass="ui-priority-primary" />

                            <p:commandButton process="@this" onclick="dlgImovel.hide()" value="Cancelar"  icon="ui-icon-trash" />
                        </div>
                        <br/>
                    </p:dialog>
                </p:panel>

                <p:dialog widgetVar="dlgUsarDadosImovel" id="dlgUsarDadosImovel" closable="true" resizable="false"
                          header="Confirmação" height="100" width="390" closeOnEscape="true" modal="true">

                    <p:outputLabel value="Deseja usar informações do imóvel antigo como modelo para este novo imóvel ?" />
                    <div class="clear-both"/>

                    <div class="buttonAction" style="margin: 10px 0 10px 0">
                        <p:commandButton value="Sim" icon="ui-icon-circle-check" process="@this"
                                         oncomplete="dlgUsarDadosImovel.hide(), dlgImovel.show()"
                                         actionListener="#{managerAverbacao.usarInformacoesImovelAntigo(true)}"
                                         update="@this, :registrationForm" styleClass="ui-priority-primary" />

                        <p:commandButton value="Não" process="@this" onclick="dlgUsarDadosImovel.hide(), dlgImovel.show()" 
                                         actionListener="#{managerAverbacao.usarInformacoesImovelAntigo(false)}"
                                         icon="ui-icon-circle-close" />
                    </div>
                </p:dialog>

                <p:dialog widgetVar="dlgProprietario" id="dlgProprietario" closable="true"
                          modal="true" header="Novo Proprietário" height="500" 
                          width="1024" closeOnEscape="true">
                    <p:tabView id="tabviewProprietarios">
                        <p:tab title="Pesquisar">

                            <div style="margin-left: 56px">
                                <p:outputLabel id="personOutputLabel" value="Pessoa" styleClass="grid_3" style="top: 6px" />
                                <div class="grid_8">
                                    <p:selectOneRadio id="personRadioButton" 
                                                      value="#{managerProprietario.pesquisarProprietario.tipoDocumento}" >
                                        <f:selectItems value="#{managerProprietario.tipoDocumentoList()}" />
                                        <p:ajax event="change" update=":registrationForm:tabviewProprietarios:proprietarioPanel" />
                                    </p:selectOneRadio>
                                </div>
                            </div>

                            <p:panel id="proprietarioPanel" 
                                     style="background: none; border: none; margin-left: -7px; margin-top: -20px;" 
                                     styleClass="container_24 clearfix both " >

                                <div class="clear"/>

                                <p:outputLabel id="tipoDocumentoLabel" 
                                               value="#{managerProprietario.pesquisarProprietario.tipoDocumento}: " 
                                               styleClass="grid_3"/>
                                <f:validateBean disabled="true" >
                                    <p:inputMask id="tipoDocumentoInput" 
                                                 value="#{managerProprietario.pesquisarProprietario.tipoDocumento.tipo eq 'CPF' ? 
                                                          managerProprietario.pesquisarProprietario.cpf : managerProprietario.pesquisarProprietario.cnpj}"
                                                 mask="#{managerProprietario.pesquisarProprietario.tipoDocumento.tipo eq 'CPF' ? 
                                                         '999.999.999-99':'99.999.999/9999-99'}"
                                                 styleClass="grid_8" > 
                                    </p:inputMask>
                                </f:validateBean>

                                <div class="clear"/>
                                <p:outputLabel value="Nome" styleClass="grid_3" for="searchNomeInputText" 
                                               rendered="#{managerProprietario.pesquisarProprietario.tipoDocumento.tipo eq 'CPF'}"/>
                                <p:inputText id="searchNomeInputText" styleClass="grid_20" 
                                             value="#{managerProprietario.pesquisarProprietario.nome}" 
                                             rendered="#{managerProprietario.pesquisarProprietario.tipoDocumento.tipo eq 'CPF'}" />

                                <p:outputLabel value="Nome Fantasia" styleClass="grid_3 companyLabel" for="razaoSocialInputText"  
                                               style="margin-left: -5px !important" 
                                               rendered="#{managerProprietario.pesquisarProprietario.tipoDocumento.tipo eq 'CNPJ'}" />
                                <p:inputText id="razaoSocialInputText" styleClass="grid_20"
                                             value="#{managerProprietario.pesquisarProprietario.nomeFantasia}" 
                                             rendered="#{managerProprietario.pesquisarProprietario.tipoDocumento.tipo eq 'CNPJ'}" />

                            </p:panel>
                            <br/>
                            <div class="buttonAction">
                                <p:commandButton value="Pesquisar" icon="ui-icon-search"
                                                 update=":registrationForm:tabviewProprietarios:resultTable" id="addButton"
                                                 styleClass="ui-priority-primary" process=":registrationForm:tabviewProprietarios"
                                                 actionListener="#{managerProprietario.pesquisar()}" /> 

                                <p:commandButton value="Limpar" icon="ui-icon-clean" process=":registrationForm:tabviewProprietarios"
                                                 update=":registrationForm:tabviewProprietarios:proprietarioPanel" 
                                                 actionListener="#{managerProprietario.limpar()}" />
                            </div >
                            <br />

                            <p:blockUI id="clockUi" block="resultPanel" trigger="addButton" > 
                                <p:graphicImage value="media/images/ajax-loader.gif"/>
                            </p:blockUI>

                            <h4 class="title">Resultado</h4>
                            <p:panel id="resultPanel" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix both ">

                                <p:dataTable id="resultTable" var="cht" value="#{managerProprietario.dataModel}"
                                             styleClass="grid_24" rowIndexVar="rowid"
                                             binding="#{managerProprietario.searchResults}"
                                             rows="5" paginator="true" lazy="true" rowKey="#{cht.id}"
                                             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                                             currentPageReportTemplate="{currentPage} de {totalPages}"
                                             paginatorPosition="bottom" emptyMessage="Nenhum registro encontrado">
                                    <f:facet name="header">
                                        Proprietários
                                    </f:facet> 
                                    <p:column headerText="Ação" style="width: 50px; vertical-align: middle;">  
                                        <p:commandButton actionListener="#{managerAverbacao.selecionaProprietario(cht)}" icon="ui-icon-check"
                                                         title="Selecionar" onsuccess="dlgProprietario.hide()" update=":registrationForm:tableProprietario" process=":registrationForm:tabviewProprietarios" />
                                    </p:column> 
                                    <p:column headerText="Nome / Fantasia" >  
                                        <h:outputLabel value="#{cht.tipoDocumento.tipo eq 'CPF' ? cht.nome : cht.nomeFantasia}" />  
                                    </p:column>
                                    <p:column headerText="Documento" >  
                                        <h:outputLabel value="#{cht.formatedDocument()}" />  
                                    </p:column>
                                </p:dataTable>
                            </p:panel>

                            <div class="buttonAction">
                                <p:commandButton process="@this" onclick="dlgProprietario.hide()" value="Fechar"  icon="ui-icon-circle-close" />
                            </div>
                        </p:tab>

                        <p:tab title="Cadastrar">

                            <p:panel id="personPanel" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix both ">
                                <h4 class="title">Dados Gerais</h4>

                                <p:outputLabel id="AddpersonOutputLabel" value="Pessoa: " styleClass="grid_3" style="top: 6px" />
                                <div class="grid_8">
                                    <p:selectOneRadio id="addPersonRadioButton" value="#{managerAverbacao.proprietario.tipoDocumento}" >
                                        <f:selectItems value="#{managerAverbacao.tipoDocumentoList()}" />
                                        <p:ajax event="change" update="personPanel" />
                                    </p:selectOneRadio>
                                </div>

                                <div class="clear-both"/>

                                <p:outputLabel for="tipoDocumentoInput"
                                               value="#{managerAverbacao.proprietario.tipoDocumento}: " 
                                               styleClass="grid_3"/>

                                <p:inputMask id="addTipoDocumentoInput"
                                             value="#{managerAverbacao.proprietario.tipoDocumento.tipo eq 'CPF' ? 
                                                      managerAverbacao.proprietario.cpf : managerAverbacao.proprietario.cnpj}"
                                             mask="#{managerAverbacao.proprietario.tipoDocumento.tipo eq 'CPF' ? 
                                                     '999.999.999-99':'99.999.999/9999-99'}"
                                             styleClass="grid_8" > 
                                </p:inputMask>
                                <div class="clear-both" />

                                <p:outputLabel value="Nome: " styleClass="grid_3" for="nomeInputText" 
                                               rendered="#{managerAverbacao.proprietario.tipoDocumento.tipo eq 'CPF'}"/>
                                <p:inputText id="nomeInputText" styleClass="grid_20 ajustInput"
                                             value="#{managerAverbacao.proprietario.nome}" 
                                             rendered="#{managerAverbacao.proprietario.tipoDocumento.tipo eq 'CPF'}" />

                                <p:outputLabel value="RG: " styleClass="grid_3" for="rgInputText" 
                                               rendered="#{managerAverbacao.proprietario.tipoDocumento.tipo eq 'CPF'}" />
                                <p:inputText id="rgInputText" styleClass="grid_8" value="#{managerAverbacao.proprietario.rg}" 
                                             rendered="#{managerAverbacao.proprietario.tipoDocumento.tipo eq 'CPF'}" />

                                <p:outputLabel value="Org. Emissor: " styleClass="grid_3" for="orgInputText" 
                                               rendered="#{managerAverbacao.proprietario.tipoDocumento.tipo eq 'CPF'}" />
                                <p:inputText id="orgInputText" styleClass="grid_8" value="#{managerAverbacao.proprietario.orgaoEmissor}" 
                                             rendered="#{managerAverbacao.proprietario.tipoDocumento.tipo eq 'CPF'}" />
                                <div class="clear"/> 
                                <p:outputLabel value="Data Nasc.: " styleClass="grid_3" for="dateNascCalendar" 
                                               rendered="#{managerAverbacao.proprietario.tipoDocumento.tipo eq 'CPF'}" />
                                <p:calendar id="dateNascCalendar" value="#{managerAverbacao.proprietario.dataNasc}" 
                                            styleClass="grid_8" 
                                            showOn="both" 
                                            locale="pt"
                                            yearRange="1900:2020"
                                            navigator="true"
                                            pattern="dd/MM/yyyy"
                                            rendered="#{managerAverbacao.proprietario.tipoDocumento.tipo eq 'CPF'}" />

                                <div class="clear"/> 
                                <p:outputLabel value="Nome Fantasia: " styleClass="grid_3 companyLabel" style="margin-left: -7px !important"
                                               for="nameFantasyInputText" rendered="#{managerAverbacao.proprietario.tipoDocumento.tipo eq 'CNPJ'}" />
                                <p:inputText id="nameFantasyInputText" styleClass="grid_20 ajustInput" 
                                             value="#{managerAverbacao.proprietario.nomeFantasia}" 
                                             rendered="#{managerAverbacao.proprietario.tipoDocumento.tipo eq 'CNPJ'}" />
                                <div class="clear"/> 
                                <br/>

                                <p:panel id="addressPanel"
                                         style="background: none; border: none; margin-left: -15px; margin-top: -25px;" 
                                         styleClass="container_24 clearfix both ">
                                    <h4 class="title">Endereço</h4>

                                    <p:outputLabel value="CEP" styleClass="grid_3" for="cepInputMask" />
                                    <p:inputMask  id="cepInputMask" styleClass="grid_4" mask="99.999-999"
                                                  value="#{managerAverbacao.proprietario.endereco.cep}" > 
                                    </p:inputMask>
                                    <div class="clear"/>

                                    <p:outputLabel value="Cod. Logra." styleClass="grid_3" 
                                                   for="codLogradouroInputText" />
                                    <p:inputText id="codLogradouroInputText" styleClass="grid_4" 
                                                 value="#{managerAverbacao.proprietario.endereco.codLogradouro}" />

                                    <p:outputLabel value="Logradouro" styleClass="grid_4 alpha" for="patioInputText" />
                                    <p:inputText id="patioInputText" styleClass="grid_12" 
                                                 value="#{managerAverbacao.proprietario.endereco.logradouro}" />

                                    <p:outputLabel value="Cod. Bairro" styleClass="grid_3" for="codBairroInputText" />
                                    <p:inputText id="codBairroInputText" styleClass="grid_4" 
                                                 value="#{managerAverbacao.proprietario.endereco.codBairro}" />

                                    <p:outputLabel value="Bairro: " styleClass="grid_4 alpha" for="bairroInputText" />
                                    <p:inputText id="bairroInputText" styleClass="grid_12" 
                                                 value="#{managerAverbacao.proprietario.endereco.bairro}" />

                                    <p:outputLabel value="Estado: " styleClass="grid_3" for="estadoInputText" />
                                    <p:inputText id="estadoInputText" styleClass="grid_4"
                                                 value="#{managerAverbacao.proprietario.endereco.uf}" />

                                    <p:outputLabel value="Município: " styleClass="grid_4 alpha" for="municipioInputText" />
                                    <p:inputText id="municipioInputText" styleClass="grid_12"
                                                 value="#{managerAverbacao.proprietario.endereco.municipio}" />

                                    <p:outputLabel value="Número: " styleClass="grid_3" for="numInputText" />
                                    <p:inputText id="numInputText" styleClass="grid_4"
                                                 value="#{managerAverbacao.proprietario.endereco.numero}" />

                                    <p:outputLabel value="Complemento" styleClass="grid_4 alpha" for="complementInputText" />
                                    <p:inputText id="complementInputText" styleClass="grid_12" 
                                                 value="#{managerAverbacao.proprietario.endereco.compl}" />

                                </p:panel>
                            </p:panel>

                            <div class="buttonAction">
                                <p:commandButton value="Adicionar" icon="ui-icon-circle-plus"
                                                 actionListener="#{managerAverbacao.addProprietario()}"
                                                 oncomplete="dlgProprietario.hide()"
                                                 process=":registrationForm:dlgProprietario"
                                                 update=":registrationForm:tableProprietario, :registrationForm:dlgProprietario"
                                                 styleClass="ui-priority-primary" />

                                <p:commandButton process="@this" onclick="dlgProprietario.hide()" value="Cancelar"  icon="ui-icon-trash" />
                            </div >
                        </p:tab>
                    </p:tabView>

                </p:dialog>

            </h:form>
        </ui:define>
    </ui:composition>

</html>
